package com.oolatina.adapters;

import com.oolatina.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

public class VideoGridAdapter extends BaseAdapter {
    private Context mContext;
	private LayoutInflater inflater;
	private ViewHolder holder;
	private String[] mLabels;

    public VideoGridAdapter(Context c) {
        mContext = c;
        mLabels = mContext.getResources().getStringArray(R.array.video_array);
        		
        try{
			inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		}catch(Exception e){}
    }

    public int getCount() {
        return mThumbIds.length;
    }

    public Object getItem(int position) {
        return null;
    }

    public long getItemId(int position) {
        return 0;
    }
    
    static class ViewHolder {
		public ImageView image;
		public TextView label;
	}

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView imageView;
        if (convertView == null) {  // if it's not recycled, initialize some attributes
        	convertView = inflater.inflate(R.layout.layout_videogrid, null);
            holder = new ViewHolder();
            holder.image = (ImageView) convertView.findViewById(R.id.image);
            holder.label = (TextView) convertView.findViewById(R.id.label);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.image.setImageResource(mThumbIds[position]);
        holder.label.setText(mLabels[position]);
        return convertView;
    }

    // references to our images
    private Integer[] mThumbIds = {
    		R.drawable.thumb_dance_shows,
    		R.drawable.thumb_dance_workshops,
    		R.drawable.thumb_dance_party,
    		R.drawable.thumb_salsa_cubaine,
    		R.drawable.thumb_salsa_portoricaine,
    		R.drawable.thumb_bachata,
            R.drawable.thumb_kizomba,
            R.drawable.thumb_reggaeton,
            R.drawable.thumb_merengue
    };
}
